<?php
/**
 * Home ControllerL load latest product in eight categories.
 * @author Kota Kakaji
 *
 */
class ControllerCommonHome extends Controller {
	public function index() {
		
		//Controller id
		$this->id       = 'content_home';
		
		//Load Language used in template file
		$this->language->load('common/home');
		
		//Page title
		$this->document->title = sprintf($this->language->get('title'), $this->config->get('config_store'));
		
		//Document description
		$this->document->description = $this->config->get('config_meta_description');
		
		//Home page flag
		$this->document->home_flg    = "on";
		$this->document->breadcrumbs = array();
		
		//Language data to show at home page
		$this->data['product_detail'] = sprintf($this->language->get('product_detail'));
		$this->data['menu_title'] = sprintf($this->language->get('menu_title'));
		$this->data['heading_title'] = sprintf($this->language->get('heading_title'), $this->config->get('config_store'));
		$this->data['welcome'] = html_entity_decode($this->config->get('config_welcome_' . $this->language->getId()));
		$this->data['text_latest'] = $this->language->get('text_latest');
		
		//Load used model and helper utility
		$this->load->model('catalog/product');
		$this->load->model('catalog/review');
		$this->load->model('tool/seo_url');
		$this->load->helper('image');
		
		$this->data['products'] = array();
		$data = $this->model_catalog_product->getProductIndexPage();
		
		$this->data['product_data'] = $data;	
		if (!$this->config->get('config_customer_price')) {
			$this->data['display_price'] = TRUE;
		} elseif ($this->customer->isLogged()) {
			$this->data['display_price'] = TRUE;
		} else {
			$this->data['display_price'] = FALSE;
		}
		
		//Load and render template file
		$this->template = $this->config->get('config_template') . 'common/home.phtml';
		$this->layout   = 'common/layout_index';
		$this->render();
	}
}
?>